﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wp.BLL;
using Wp.DAL;

public partial class Admin_Modules_Pages_Default : System.Web.UI.Page
{
    //public static int PAGE_SIZE = 50;
    //public int PageIndex { get; set; }
    //public int TermTaxonomyId { get; set; }
    public string Approved { get; set; }
    public static string PostType = "page";
    protected void Page_Load(object sender, EventArgs e)
    {


        if (!IsPostBack)
        {
            //LoadDDL();
            GetPropertyFromQueryString();
            LoadData(Approved);
        }
    }
    void GetPropertyFromQueryString()
    {
        //PageIndex = CommonHelper.QueryStringInt("PageIndex", 1);
        //TermTaxonomyId = CommonHelper.QueryStringInt("TermTaxonomyId", -1);
        Title = CommonHelper.QueryString("Title", "");
        Approved = CommonHelper.QueryString("Approved", "");
        ddlStatus.SelectedValue = Approved;
        //ddlTermTaxonomy.SelectedValue = TermTaxonomyId.ToString();
        //txtTitle.Text = Title;
    }
    void GetPropertyFromForm()
    {
        //TermTaxonomyId = ddlTermTaxonomy.SelectedValue.ToInt();
        Approved = ddlStatus.SelectedValue;
    }
    //void LoadDDL()
    //{
    //    ddlTermTaxonomy.DataSource = TblTermTaxonomyManager.CreateInstant().SelectTblTermsTaxonomyGetChildFormat(null, Taxonomy); ;
    //    ddlTermTaxonomy.DataTextField = "Name";
    //    ddlTermTaxonomy.DataValueField = "Id";
    //    ddlTermTaxonomy.DataBind();
    //}
    void LoadData(string Approved)
    {
        //int TotalRow = 0;
        List<TblCommentsEntity> ls = TblCommentsManager.CreateInstant().SelectByPost(null, null, Approved,1000);
        rpt.DataSource = ls;
        rpt.DataBind();
        //smartPager1.PageSize = smartPager.PageSize = PAGE_SIZE;
        //smartPager1.QueryStringKey = smartPager.QueryStringKey = "PageIndex";
        //smartPager1.RowCount = smartPager.RowCount = TotalRow;
        //smartPager1.NavigatePreviousText = smartPager.NavigatePreviousText = "<<";
        //smartPager1.NavigateNextText = smartPager.NavigateNextText = ">>";
        ////smartPager.Display=3;
        //smartPager1.UrlFormatString = smartPager.UrlFormatString = "Default.aspx?PageIndex={0}";
        //smartPager1.Visible = smartPager.Visible = TotalRow > PAGE_SIZE;
    }
    protected void btnSeach_Click(object sender, EventArgs e)
    {
        GetPropertyFromForm();
        string Url = string.Format("Default.aspx?Approved={0}", Approved) + "&PageIndex=1";
        Response.Redirect(Url);
    }
    protected void rpt_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            DropDownList ddl = (DropDownList)e.Item.FindControl("DropDownList1");
            TblCommentsEntity item = (TblCommentsEntity)e.Item.DataItem;
            ddl.SelectedValue = item.Approved;
        }
    }
}